package com.group3.admin.servlet;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.group3.admin.service.IAMerchantService;
import com.group3.admin.service.impl.AMerchantServiceImpl;
import com.group3.admin.util.JsonUtil;


/**
 * Servlet implementation class MidListServlet
 */
public class MidListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       private IAMerchantService service = new AMerchantServiceImpl();
    /**
     * @see HttpServlet#HttpServlet()
     */
    public MidListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		getMidList(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		getMidList(request, response);
	}
	
	private void getMidList(HttpServletRequest request, HttpServletResponse response) throws IOException{
//		String type = request.getParameter("type");
		List<String> list=service.queryMidList();
		if(list!=null){
			System.out.println("response to customer success ");
			System.out.println("list is "+list);
		}
		OutputStream os=response.getOutputStream();
		String midList=JsonUtil.getInstance().ObjectToJson(list);
		os.write(midList.getBytes());
	}

}

